﻿using SIIE_ERP.BaseDatos.Inventarios.Catalogos;
using SIIE_ERP.Codigo;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Elysium.Demo.PuntoVenta.Transacciones
{
    /// <summary>
    /// Lógica de interacción para UserControl_TA1.xaml
    /// </summary>
    public partial class UserControl_TA2 : UserControl
    {
        private UsuarioActivo _sesion;
        private int _Compania;

        public UserControl_TA2(ref UsuarioActivo sesion, int Compania)
        {
            InitializeComponent();
            this._sesion = sesion;
            this._Compania = Compania;

            dbo_Cat_Articulo dbo_Articulo = new dbo_Cat_Articulo(_sesion.RFC, _sesion.UserName);

            var dt_Datos = dbo_Articulo.GetArticulos_TA(_Compania.ToString()).Rows;

            DatosDataGrid.Items.Clear();
            foreach (DataRow d in dt_Datos)
            {
                int Id_Articulo = Int32.Parse( d["Id_Articulo"].ToString());
                var ProductCode = d["Descripcion"].ToString();
                var Descripcion = d["Nombre"].ToString();
                int Monto = Int32.Parse( d["Precio_Lista"].ToString());
                int CompaniaCelular = Int32.Parse( d["Clave"].ToString());

                DatosDataGrid.Items.Add(new SIIE_ERP.BaseDatos.Configuracion.dbo_Trans_TiempoAire_RFC.ArticulosTA(Id_Articulo, ProductCode, Descripcion, Monto, CompaniaCelular));
            }            
        }

        private void AbrirLinkDatos_Click(object sender, RoutedEventArgs e)
        {
            SIIE_ERP.BaseDatos.Configuracion.dbo_Trans_TiempoAire_RFC.ArticulosTA Articulo = ((FrameworkElement)sender).DataContext as SIIE_ERP.BaseDatos.Configuracion.dbo_Trans_TiempoAire_RFC.ArticulosTA;

            Window window = new Window
            {
                Title = "Número Celular",
                Height = 415,
                Width = 735,
                WindowStyle = System.Windows.WindowStyle.ToolWindow,
                ResizeMode = System.Windows.ResizeMode.NoResize,
                Content = new UserControl_TA3(ref _sesion, Articulo)
            };

            Window parentWindow = (Window)this.Parent;
            parentWindow.Close();

            window.ShowDialog();
        }
    }
}
